package com.wuyou.designPatterns.factory.abstractfactory.listfactory;

import com.wuyou.designPatterns.factory.abstractfactory.factory.Item;
import com.wuyou.designPatterns.factory.abstractfactory.factory.Page;

import java.util.Iterator;

public class ListPage extends Page {
    public ListPage(String title, String author) {
        super(title, author);
    }

    @Override
    public String makeHTML() {
        StringBuffer buffer = new StringBuffer();
        buffer.append("<html><head><title>").append(title).append("</title></head> \n").append("<body>\n").append("<h1>"+title+"</h1>\n").append("<ul>\n");
        Iterator<Item> iterator = content.iterator();
        while (iterator.hasNext()){
            buffer.append(iterator.next().makeHTML());
        }
        buffer.append("</ul>\n").append("<hr><address>").append(author).append("</address>").append("</body></html>\n");
        return buffer.toString();
    }
}
